﻿#region Copyright(C) 2012 NCS Pte. Ltd. All rights reserved.

// ==================================================================================================
// Copyright(C) 2012 NCS Pte. Ltd. All rights reserved.
//
// SYSTEM NAME	:   iConnect.Azure Application Framework
// COMPONENT ID :   NCS.IConnect.Azure.Diagnostics.AzureStorage.ITableServiceContext
// COMPONENT DESC:  	
//
// CREATED DATE/BY:  08 June 2012 / Lu Ya Ming
//
// REVISION HISTORY:	
// DATE/BY			SR#/CS/PM#/OTHERS		DESCRIPTION OF CHANGE
// ==================================================================================================

#endregion

using System.Data.Services.Client;
using System.Linq;

using Microsoft.WindowsAzure.StorageClient;

namespace NCS.IConnect.Cloud.Core.AzureStorage
{
    /// <summary>
    /// The interface of table service context.
    /// </summary>
    public interface ITableServiceContext
    {
        /// <summary>
        /// Gets or sets the retry policy.
        /// </summary>
        /// <value>
        /// The retry policy.
        /// </value>
        RetryPolicy RetryPolicy { get; set; }

        /// <summary>
        /// Creates the query.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entitySetName">Name of the entity set.</param>
        /// <returns></returns>
        IQueryable<T> CreateQuery<T>(string entitySetName);

        /// <summary>
        /// Adds the object.
        /// </summary>
        /// <param name="entitySetName">Name of the entity set.</param>
        /// <param name="entity">The entity.</param>
        void AddObject(string entitySetName, object entity);

        /// <summary>
        /// Attaches to.
        /// </summary>
        /// <param name="entitySetName">Name of the entity set.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="etag">The etag.</param>
        void AttachTo(string entitySetName, object entity, string etag);

        /// <summary>
        /// Updates the object.
        /// </summary>
        /// <param name="entity">The entity.</param>
        void UpdateObject(object entity);

        /// <summary>
        /// Saves the changes with retries.
        /// </summary>
        /// <param name="options">The options.</param>
        void SaveChangesWithRetries(SaveChangesOptions options);
    }
}
